#ifndef T1_ARCH_H_
#define T1_ARCH_H_

#include "regs.h"
#include "m14kc.h"

#define Uncache2Cache(addr)     ((addr) - (IO_BASE - MEM_BASE))
#define Cache2Uncache(addr)     ((addr) + (IO_BASE - MEM_BASE))

#ifdef CONFIG_MMU
#define V_APP2KERNEL(vaddr)		(vaddr+0x20000000)
#define V_KERNEL2APP(vaddr)		(vaddr-0x20000000)
#else
#define V_APP2KERNEL(vaddr)		(vaddr)
#define V_KERNEL2APP(vaddr)		(vaddr)
#endif

static inline int fls(int word)
{
        __asm__ ("clz %0, %1" : "=r" (word) : "r" (word));

        return 32 - word;
}

static inline int ffs(int word)
{
        if (!word)
                return 0;

        return fls(word & -word);
}

#define ffz(x) ffs( ~(x) )

static inline void __enable_interrupt()               { __asm__ volatile ("ei"); }
static inline void __disable_interrupt()              { __asm__ volatile ("di"); }
static inline void __cpu_sleep()                      {
                                                         __asm__ volatile("nop");
                                                         __asm__ volatile("nop");
                                                         __asm__ volatile("nop");
                                                         __asm__ volatile("wait");
                                                         __asm__ volatile("nop");
                                                         __asm__ volatile("nop");
                                                         __asm__ volatile("nop");
                                                      }




#define ARCH_VERSION    "T1.06"

#endif /* T1_ARCH_H_ */
